package com.hengpeng.itfin.exception;

import com.hengpeng.common.constant.Constant;
import com.hengpeng.common.exception.ServiceResult;

/**
 * <pre>
 * 业务交易错误(意料之外的)异常类型
 * 
 * 适用范围：
 * 网站异常
 * </pre>
 * @author linriqing
 * @version 1.0, 2008-8-13
 */
public class TransException extends RuntimeException
{

	private static final long serialVersionUID = 4953260375190880876L;

	/**
	 * 异常代码
	 */
	private String exceptionCode = Constant.TRANSACTION_RESPONSE_CODE_UNKOWN;

	/**
	 * 异常信息
	 */
	private String exceptionMsg = Constant.TRANSACTION_RESPONSE_MESSAGE_UNKOWN;

	/**
	 * 原始异常对象
	 */
	private Throwable incException;

	/**
	 * 构造函数
	 */
	public TransException()
	{
		super();
	}

	/**
	 * 构造函数
	 * @param result 业务方法返回对象
	 */
	public TransException(ServiceResult<?> result)
	{
		super(result.getMessage(), result.getException());
		this.incException = result.getException();
		this.exceptionCode = result.getCode();
		this.exceptionMsg = result.getMessage();
	}

	/**
	 * 构造函数
	 * @param message 异常信息
	 */
	public TransException(String message)
	{
		super(message);
	}

	/**
	 * 构造函数
	 * @param errCode 异常代码
	 * @param message 异常信息
	 */
	public TransException(String errCode, String message)
	{
		super(message);
		this.exceptionCode = errCode;
		this.exceptionMsg = message;
	}

	/**
	 * 构造函数
	 * @param errCode 异常代码
	 * @param message 异常信息
	 * @param cause 原始异常对象
	 */
	public TransException(String errCode, String message, Throwable cause)
	{
		super(message, cause);
		this.exceptionCode = errCode;
		this.exceptionMsg = message;
		this.incException = cause;
	}

	/**
	 * 构造函数
	 * @param message 异常信息
	 * @param cause 原始异常对象
	 */
	public TransException(String message, Throwable cause)
	{
		super(message, cause);
	}

	/**
	 * 构造函数
	 * @param cause 原始异常对象
	 */
	public TransException(Throwable cause)
	{
		super(cause);
	}

	public String getExceptionCode()
	{
		return exceptionCode;
	}

	public void setExceptionCode(String exceptionCode)
	{
		this.exceptionCode = exceptionCode;
	}

	public String getExceptionMsg()
	{
		return exceptionMsg;
	}

	public void setExceptionMsg(String exceptionMsg)
	{
		this.exceptionMsg = exceptionMsg;
	}

	public Throwable getIncException()
	{
		return incException;
	}

	public void setIncException(Throwable incException)
	{
		this.incException = incException;
	}

}